package MR_process.MR3;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.parquet.hadoop.ParquetInputFormat;
import org.apache.parquet.hadoop.ParquetOutputFormat;

import MR_process.Bean2;
import MR_process.Bean3;

public class Driver3 {
    public static void main(String[] args) throws Exception {
        // 配置文件
        Configuration conf = new Configuration();

        // 将输出 Schema 设置到 Job
        Job job = Job.getInstance(conf, "MR3");
        // 配置 Job
        job.setJarByClass(Driver3.class);

        // 设置 Mapper 和 Reducer
        job.setMapperClass(Map3.class);
        job.setReducerClass(Reduce3.class);

        // 设置 Mapper 和 Reducer 的输出类型
        job.setMapOutputKeyClass(Text.class);
        job.setMapOutputValueClass(Bean2.class);
        job.setOutputKeyClass(Bean3.class);
        job.setOutputValueClass(NullWritable.class);

        // 设置输入输出格式
        // job.setInputFormatClass(ParquetInputFormat.class);
        // job.setOutputFormatClass(ParquetOutputFormat.class);

        // 设置输入输出路径
        job.setNumReduceTasks(5);
        Path inputPath = new Path("/root/autodl-tmp/MR/bio_ir/out2");
        Path outputPath = new Path("/root/autodl-tmp/MR/bio_ir/out3");
        ParquetInputFormat.addInputPath(job, inputPath);
        ParquetOutputFormat.setOutputPath(job, outputPath);

        // 提交任务
        System.exit(job.waitForCompletion(true) ? 0 : 1);
    }
}
